home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / mempools.lha / mempools / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-04  |  2.7 KB  |  108 lines

  1. /**
  2. ***  MemPools:    malloc() replacement using standard Amiga pool functions.
  3. ***  Copyright    (C)  1994    Jochen Wiedmann
  4. ***
  5. ***  This program is free software; you can redistribute it and/or modify
  6. ***  it under the terms of the GNU General Public License as published by
  7. ***  the Free Software Foundation; either version 2 of the License, or
  8. ***  (at your option) any later version.
  9. ***
  10. ***  This program is distributed in the hope that it will be useful,
  11. ***  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ***  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ***  GNU General Public License for more details.
  14. ***
  15. ***  You should have received a copy of the GNU General Public License
  16. ***  along with this program; if not, write to the Free Software
  17. ***  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ***
  19. ***
  20. ***  This file contains the initialization stuff.
  21. ***
  22. ***
  23. ***  Computer:    Amiga 1200
  24. ***
  25. ***  Compilers: Dice 3.01
  26. ***        SAS/C 6.3
  27. ***        gcc 2.6.1
  28. ***
  29. ***
  30. ***  Author:    Jochen Wiedmann
  31. ***        Am Eisteich 9
  32. ***      72555 Metzingen
  33. ***        Germany
  34. ***
  35. ***        Phone: (0049) 7123 14881
  36. ***        Internet: jochen.wiedmann@uni-tuebingen.de
  37. **/
  38.  
  39.  
  40. /***************************************************************************
  41. ***
  42. ***  This file uses the auto initialization possibilities of Dice, gcc and
  43. ***  SAS/C, respectively.
  44. ***
  45. ***  Dice does this by using the keywords __autoinit and __autoexit, SAS
  46. ***  uses names beginning with _STI or _STD, respectively. gcc uses the
  47. ***  asm() instruction, to emulate C++ constructors and destructors.
  48. ***
  49. ***************************************************************************/
  50.  
  51.  
  52. /*
  53.     Include files and compiler specific stuff
  54. */
  55. #include <stdlib.h>
  56. #include <exec/types.h>
  57. #include <clib/alib_protos.h>
  58.  
  59. #if defined(__SASC)  ||  defined(__GNUC__)
  60. #define __autoinit
  61. #define __autoexit
  62. #elif !defined(_DCC)
  63. #error "Don't know how to handle your compiler."
  64. #endif
  65.  
  66.  
  67.  
  68.  
  69. APTR __MemPool;
  70. extern ULONG __MemPoolPuddleSize;
  71. extern ULONG __MemPoolThreshSize;
  72. extern ULONG __MemPoolFlags;
  73.  
  74.  
  75. STATIC __autoinit VOID _STIInitMemFunctions(VOID)
  76.  
  77. { if (!(__MemPool = LibCreatePool(__MemPoolFlags, __MemPoolPuddleSize, __MemPoolThreshSize)))
  78.   {
  79. #if defined(__SASC)
  80.     { extern VOID _XCEXIT(LONG);
  81.       _XCEXIT(20);
  82.     }
  83. #elif defined(_DCC)
  84.     { extern VOID _AutoFail0(VOID);
  85.       _AutoFail0();
  86.     }
  87. #elif defined(__GNUC__)
  88.     { abort();
  89.     }
  90. #endif
  91.   }
  92. }
  93.  
  94.  
  95.  
  96. STATIC __autoexit VOID _STDTerminateMemFunctions(VOID)
  97.  
  98. { if (__MemPool)
  99.   { LibDeletePool(__MemPool);
  100.   }
  101. }
  102.  
  103.  
  104. #if defined(__GNUC__)
  105. asm ("  .text;  .stabs \"___CTOR_LIST__\",22,0,0,__STIInitMemFunctions");
  106. asm ("  .text;  .stabs \"___DTOR_LIST__\",22,0,0,__STDTerminateMemFunctions");
  107. #endif
  108.